package com.tuanzi.loan.web.bean.family;

import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.web.configuration.JSFListingBean;

import com.tuanzi.loan.vo.request.family.MobileCodeSendRecordSearchRequest;
import com.tuanzi.loan.vo.response.family.MobileCodeSendRecordSearchResponse;
import com.tuanzi.loan.web.lazy.family.MobileCodeSendRecordDataModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;
import java.util.Calendar;

/**
 * 手机验证码发送记录
 * @author JinRuiyang 2017/12/21 16:49:01
 */
@Debug
@Data
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class MobileCodeSendRecordBean extends JSFListingBean<MobileCodeSendRecordSearchRequest, MobileCodeSendRecordSearchResponse> {
    @PostConstruct
    private void init() {
        initLazyDataModel();
    }

    public void onReset() {
        initLazyDataModel();
    }

    public void onRefresh(){
        lazyDataModel = new MobileCodeSendRecordDataModel($);
        addSuccessfullyMessage();
    }

    private void initLazyDataModel() {
        $ = new MobileCodeSendRecordSearchRequest();
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        $.setStartTime(calendar.getTime());
        lazyDataModel = new MobileCodeSendRecordDataModel($);
    }
}